package itheima.zuoye.Test6;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class test {
    public static void main(String[] args) {
        Collection<String> c = new ArrayList<>();
        c.add("javaEE企业级开发指南");
        c.add("Oracle高级编程");
        c.add("MySQL从入门到精通");
        c.add("java构架师之路");
        print(c);
        print1(c);
        print2(c);
        print3(c);

    }
    public static void print(Collection<String> c) {
        Iterator<String> it = c.iterator();
        System.out.println("===所有元素如下===");
        while (it.hasNext()) {
            System.out.println(it.next());
        }


    }
    public static void print1(Collection<String> c) {
        System.out.println("===书名小于10个字符的元素如下===");
        Iterator<String> it = c.iterator();
        while (it.hasNext()) {
            String s = it.next();
            if (s.length() < 10) {
                System.out.println(s);
            }
        }




    }
    public static void print2(Collection<String> c) {
        System.out.println("===书中包含“java”的元素如下===");
        Iterator<String> it = c.iterator();
        while (it.hasNext()) {
            String s = it.next();
            if (s.contains("java")) {
                System.out.println(s);
            }
        }
    }
    public static void print3(Collection<String> c) {
        System.out.println("===删除“oracle”的元素如下===");
        Iterator<String> it = c.iterator();
        while (it.hasNext()) {
            String s = it.next();
            if (s.contains("Oracle")) {
                it.remove();

            }

        }
        System.out.println(c);
    }
}
